﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Patent.DBUtility;
using Patent.Json;
using System.Net.Json;
using System.Data.SqlClient;

public partial class Processing_IPC : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string parent = Request.QueryString["parent"].ToUpper();
        if (parent == "IPC" || parent == "FL" || parent == "WGFL")
        {

        }
        else
        {
            getIPC(parent);
        }
    }

    /// <summary>
    /// 格式化传输数据
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    public bool formateDatSet(DataSet data)
    {
        return true;
    }

    /// <summary>
    /// 根据父节点得出子结点
    /// </summary>
    /// <param name="parent">父亲节点</param>
    /// <returns>子结点已xml格式</returns>
    public void getIPC(string parent)
    {
        SQLHelper helper = new SQLHelper();

        DataSet data = new DataSet();
        SqlParameter[] param = new SqlParameter[1];
        param[0] = helper.CreateInParam("@parentIPC",SqlDbType.VarChar,14,parent);
        helper.RunProc("pro_QueryIPC",param,ref data);
        JsonObjectCollection collection;
        JsonArrayCollection s = new JsonArrayCollection();

        string id = "";
        for (int i = 0; i < data.Tables[0].Rows.Count; i++)
        {
            collection = new JsonObjectCollection();
            id =data.Tables[0].Rows[i]["category"].ToString();
            collection.Add(new JsonStringValue("id", id));
            collection.Add(new JsonStringValue("text", id + "    " + data.Tables[0].Rows[i]["description"].ToString() + ""));
            if ((id.Contains("/")&&!id.Contains("/00"))||id.Contains("-"))
            {
                collection.Add(new JsonBooleanValue("leaf", true));
            }
            else
            {
                
                collection.Add(new JsonBooleanValue("leaf", false));
            }
            collection.Add(new JsonStringValue("qtip", data.Tables[0].Rows[i]["description"].ToString() + ""));
            //collection.Add(new JsonBooleanValue("checked", false));
            //s.Add(collection);
            s.Insert(s.Count, collection);
        }

        //SystemError.CreateErrorLog(s.ToString());
        Response.Write(s);
        Response.End();
        Response.Flush();

    }

   
}
